﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ImportOrder.ascx.cs" Inherits="ERP.PageUC.ImportOrder" %>
<asp:UpdatePanel ID="upDateAll" runat="server">
    <ContentTemplate>
        <!---------------Toolbar---------------->
            <div class="toolbar-main">
                <asp:LinkButton ID="btnAdd" CssClass="btn btn-default btn-sm" runat="server" OnClick="btnAdd_Click"><i class="fa fa-pencil-square-o"></i> Thêm mới</asp:LinkButton>
                <asp:LinkButton ID="btnDelete" CssClass="btn btn-default btn-sm" runat="server" OnClientClick="return confirmCheckIn(this)" OnClick="btnDelete_Click"><i class="fa fa-trash-o"></i> Xoá</asp:LinkButton>
                <asp:LinkButton ID="btnExcel" CssClass="btn btn-default btn-sm" runat="server" OnClick="btnExcel_Click"><i class="fa fa-file-excel-o"></i> Xuất file Excel</asp:LinkButton>
            </div>
        <!---------------Toolbar---------------->

        <%=StrAlert %>
        <div class="table-responsive">
            <asp:ListView ID="ListViewAllOrder" runat="server" DataKeyNames="Id" OnItemCommand="ListViewAllOrder_ItemCommand" OnItemDataBound="ListViewAllOrder_ItemDataBound">
                <LayoutTemplate>
                    <table id="MyTableListViewAllOrder" class="tablesorter">
                        <thead>
                            <tr>
                                <th style="text-align: center" data-sorter="false" data-filter="false">STT</th>
                                <th style="text-align: center" data-sorter="false" data-filter="false">
                                    <input type="checkbox" onchange="checkAll('#chkAll','chkList')" id="chkAll" />
                                </th>
                                <th style="text-align: center" class="filter-select" data-placeholder="--Lọc theo người đặt--">Người lập phiếu</th>
                                <th style="text-align: center" data-filter="false">Mã phiếu nhập</th>
                                <th style="text-align: center" data-filter="false">Ngày lập phiếu</th>
                                <th style="text-align: center" data-filter="false">Tên vật tư</th>
                                <th style="text-align: center" data-filter="false">Số lượng</th>
                                <th style="text-align: center" data-filter="false">Đơn giá</th>
                                <th style="text-align: center" data-filter="false">Tổng tiền</th>
                                <th style="text-align: center" data-filter="false">Chi nhánh</th>
                                <th style="text-align: center" data-filter="false">Kho</th>
                                <th style="text-align: center" data-filter="false">Phòng chứa</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr id="itemPlaceholder" runat="server">
                            </tr>
                        </tbody>
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr runat="server"  class="warning">
                        <td style="text-align: center"><%# Eval("Rows_ID") %></td>
                        <td style="text-align: center">
                            <asp:CheckBox ClientIDMode="Static" ID="chkList" CssClass="chkList" runat="server" />
                        </td>
                        <td style="text-align:left">
                            <asp:LinkButton ID="link_FullName" CssClass="note" CommandName="Acceept" runat="server" Text='<%# Eval("FullName") %>'></asp:LinkButton>
                        </td>
                        <td style="text-align:right">
                            <asp:LinkButton ID="link_OrderBuyCode" CssClass="note" CommandName="Acceept" runat="server" Text='<%# Eval("Order_Buy_Code") %>'></asp:LinkButton>
                        </td>
                        <td style="text-align:right">
                            <asp:LinkButton ID="link_DateBegin" CssClass="note" CommandName="Acceept" runat="server" Text='<%# Eval("DateBegin","{0:dd/MM/yyyy}") %>'></asp:LinkButton>
                        </td>
                        <td style="text-align:left">
                            <asp:LinkButton ID="linkOrder_Materials_Name" CssClass="note" CommandName="Acceept" runat="server" Text='<%# Eval("Materials_Name") %>'></asp:LinkButton>
                        </td>
                        <td style="text-align:center">
                            <asp:LinkButton ID="linkOrder_Quality" CssClass="note" CommandName="Acceept" runat="server" Text='<%# Eval("Quality") %>'></asp:LinkButton>
                        </td>
                        <td style="text-align:right">
                            <asp:LinkButton ID="link_Price" CssClass="note" CommandName="Acceept" runat="server" Text='<%# Eval("Price") %>'></asp:LinkButton>
                        </td>
                        <td style="text-align:right">
                            <asp:LinkButton ID="linkOrder_TotalPrice" CssClass="note" CommandName="Acceept" runat="server" Text='<%# Eval("TotalPrice") %>'></asp:LinkButton>
                        </td>
                        <td style="text-align:left">
                            <asp:Label ID="lbIDOrder_Branch_Name" runat="server" Text='<%# Eval("Branch_Name") %>'></asp:Label>
                        </td>
                        <td style="text-align:center">
                            <asp:Label ID="lbIDOrder_Warehouse_Name" runat="server" Text='<%# Eval("Warehouse_Name") %>'></asp:Label>
                        </td>
                        <td style="text-align:center">
                            <asp:Label ID="lbRoom_Name" runat="server" Text='<%# Eval("Room_Name") %>'></asp:Label>
                        </td>
                    </tr>
                </ItemTemplate>
                <EmptyDataTemplate>
                    <div class='alert alert-danger'>
                        <a href='#' class='close' data-dismiss='alert'>&times;</a>
                        Không tìm thấy mẫu tin nào !
                    </div>
                </EmptyDataTemplate>
            </asp:ListView>
        </div>
        <div class="pager pagerMyTableListViewAllOrder">
            <div class="toolbar-main">
            <asp:TextBox ID="txtSearch" CssClass="textbox-search" runat="server" />
            <asp:LinkButton ID="btnSearch" CssClass="btn btn-default btn-xs" title="Tìm kiếm" runat="server" OnClick="btnSearch_Click"><i class="fa fa-search"></i></asp:LinkButton>
            <asp:LinkButton ID="btnReload" CssClass="btn btn-default btn-xs" title="Làm tươi" runat="server" OnClick="btnReload_Click"><i class="fa fa-refresh"></i></asp:LinkButton>
            <span>Trang</span>
                <select class="gotoPage" title="Select page number"></select>
                <img src="../Content/TableSort/addons/pager/icons/first.png" class="first" alt="First" />
                <img src="../Content/TableSort/addons/pager/icons/prev.png" class="prev" alt="Prev" />
                <span class="pagedisplay"></span>
                <img src="../Content/TableSort/addons/pager/icons/next.png" class="next" alt="Next" />
                <img src="../Content/TableSort/addons/pager/icons/last.png" class="last" alt="Last" />
            </div>
        </div>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnAdd" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="btnDelete" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="btnReload" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>

<!----------------Loading---------------->
<asp:UpdateProgress ID="upDateProcess" runat="server" AssociatedUpdatePanelID="upDateAll">
    <ProgressTemplate>
        <div class="divWaiting">
            <img src="../Images/ajax-loader.gif" alt="Loading"  />
            <span class="process-template-text">Đang tải dữ liệu...</span>
        </div>
    </ProgressTemplate>
</asp:UpdateProgress>
<!--------------Kêt-thúc----------------->

<!-------------Edit-Dữ-Liệu-------------->
<div id="importorder" title="Lập phiếu nhập kho">
    <asp:UpdatePanel ID="upDateOrderBuy" UpdateMode="Conditional" ChildrenAsTriggers="true" runat="server">
        <ContentTemplate>
            <div class="btn-toolbar">
                <div class="btn-group">
                    <asp:LinkButton ID="btnSave" CssClass="btn btn-default btn-sm" runat="server" OnClick="btnSave_Click"><i class="fa fa-floppy-o"></i> Lưu lại</asp:LinkButton>
                    <asp:LinkButton ID="btnReloadPopup" CssClass="btn btn-default btn-sm" runat="server" OnClick="btnReloadPopup_Click"><i class="fa fa-refresh"></i> Làm tươi</asp:LinkButton>
                    <asp:LinkButton ID="btnAddMaterials_Popup"  CssClass="btn btn-default btn-sm" runat="server" OnClick="btnAddMaterials_Popup_Click"><i class="fa fa-refresh"></i> Thêm vật tư</asp:LinkButton>
                </div>
                <label class="validateTips"></label>
                <input type="hidden" id="lbID" runat="server" />
            </div>

            <div class="ui-main-order">
                <ul class="breadcrumb">
                  <li class="active"><span style="color:red"> Thông tin phiếu nhập kho </span></li>
                </ul>

                <div class="col-main">
                    <div class="col-left">
                        <label class="labelpopup">Người lập phiếu <span style="color: Red">(*) </span></label>
                    </div>

                    <div class="col-right">
                        <asp:DropDownList ID="drNguoiLapPhieu" CssClass="textbox_child_text-order-4" runat="server" AutoPostBack="true" AppendDataBoundItems="true" OnSelectedIndexChanged="drNguoiLapPhieu_SelectedIndexChanged">
                            <asp:ListItem Value="-1">--Chọn người lập phiếu--</asp:ListItem>
                        </asp:DropDownList>
                    </div>
                <div class="clr"></div>
                </div>

                <div class="col-main">
                    <div class="col-left">
                        <label class="labelpopup">Bộ phận </label>
                    </div>

                    <div class="col-right">
                        <asp:TextBox ID="txtBoPhan" CssClass="textbox_child_text-order" runat="server"></asp:TextBox>
                    </div>
                <div class="clr"></div>
                </div>

                <div class="col-main">
                    <div class="col-left">
                        <label class="labelpopup">Chức vụ </label>
                    </div>

                    <div class="col-right">
                        <asp:TextBox ID="txtChucVu" CssClass="textbox-muiti-order-3" runat="server"></asp:TextBox>
                    </div>
                <div class="clr"></div>
                </div>

                <div class="col-main">
                    <div class="col-left">
                        <label class="labelpopup">Diễn giải </label>
                    </div>

                    <div class="col-right">
                        <asp:TextBox ID="txtDienGiai" CssClass="textbox-muiti-order" TextMode="MultiLine" runat="server"></asp:TextBox>
                    </div>
                <div class="clr"></div>
                </div>

                <div class="col-main">
                    <div class="col-left">
                        <label class="labelpopup">Ghi chú </label>
                    </div>

                    <div class="col-right">
                        <asp:TextBox ID="txtGhiChu" CssClass="textbox-muiti-order-3" runat="server"></asp:TextBox>
                    </div>
                <div class="clr"></div>
                </div>
            </div>

            <div class="ui-main-order-right-1">
                <ul class="breadcrumb">
                  <li class="active"><span style="color:red"> Chứng từ </span></li>
                </ul>

                <div class="col-main">
                    <div class="col-left">
                        <label class="labelpopup">Chứng từ nhập</label>
                    </div>

                    <div class="col-right">
                        <asp:DropDownList ID="drChungTuNhap" CssClass="textbox_child_text-order-4" runat="server" AppendDataBoundItems="true" AutoPostBack="true" OnSelectedIndexChanged="drChungTuNhap_SelectedIndexChanged">
                            <asp:ListItem Value="-1">--Chọn chứng từ nhập--</asp:ListItem>
                        </asp:DropDownList>
                    </div>
                <div class="clr"></div>
                </div>
                <div class="clr"></div>
                <div class="col-main">
                    <div class="col-left">
                        <label class="labelpopup">Ngày nhập </label>
                    </div>

                    <div class="col-right">
                        <asp:TextBox ID="txtNgayDatHang" CssClass="textbox_child_text_ngay" runat="server"></asp:TextBox>
                    </div>
                <div class="clr"></div>
                </div>
                <div class="clr"></div>
                <div class="col-main">
                    <div class="col-left">
                        <label class="labelpopup">Chọn chi nhánh </label>
                    </div>

                    <div class="col-right">
                        <asp:DropDownList ID="drChiNhanh" CssClass="textbox_child_text-order-4" runat="server" AutoPostBack="true" OnSelectedIndexChanged="drChiNhanh_SelectedIndexChanged">
                        </asp:DropDownList>
                    </div>
                <div class="clr"></div>
                </div>
                <div class="clr"></div>
                <div class="col-main">
                    <div class="col-left">
                        <label class="labelpopup">Chọn kho </label>
                    </div>

                    <div class="col-right">
                        <asp:DropDownList ID="drChonKho" CssClass="textbox_child_text-order-4" runat="server" AutoPostBack="true" OnSelectedIndexChanged="drChonKho_SelectedIndexChanged">
                        </asp:DropDownList>
                    </div>
                <div class="clr"></div>
                </div>
                <div class="clr"></div>
                <div class="col-main">
                    <div class="col-left">
                        <label class="labelpopup">Chọn phòng chứa </label>
                    </div>

                    <div class="col-right">
                        <asp:DropDownList ID="drPhongChua" CssClass="textbox_child_text-order-4" runat="server" AutoPostBack="true">
                        </asp:DropDownList>
                    </div>
                <div class="clr"></div>
                </div>
            </div>

            <div class="ui-main-order-grid-1">
                <div class="table-responsive">
                    <asp:ListView ID="ListViewOrderImportTemp" runat="server" OnItemCommand="ListViewOrderDetailTemp_ItemCommand">
                        <LayoutTemplate>
                            <table class="table table-bordered">
                                <thead>
                                    <tr>
                                        <th style="text-align: center">STT</th>
                                        <th style="text-align:center">Mã vật tư</th>
                                        <th style="text-align:center">Tên vật tư</th>
                                        <th style="text-align:center">Số lượng</th>
                                        <th style="text-align:center">Đơn giá</th>
                                        <th style="text-align:center">Tổng tiền</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr id="itemPlaceholder" runat="server">
                                    </tr>
                                </tbody>
                            </table>
                        </LayoutTemplate>

                        <ItemTemplate>
                            <tr runat="server" class="warning">
                                <td>
                                    <asp:Label ID="lbRowsID" runat="server" Text='<%# Eval("Rows_ID") %>' />
                                    <asp:Label ID="lbID" Visible="false" runat="server" Text='<%# Eval("Order_Buy_Detail_Id") %>' />
                                    <asp:Label ID="lbIDMaterials_Id" Visible="false" runat="server" Text='<%# Eval("Materials_Id") %>' />
                                    <asp:Label ID="lbOrder_Detail_CK_Percent" Visible="false" runat="server" Text='<%# Eval("Order_Detail_CK_Percent") %>' />
                                    <asp:Label ID="lbOrder_Detail_CK" Visible="false" runat="server" Text='<%# Eval("Order_Detail_CK") %>' />
                                    <asp:Label ID="lbOrder_Detail_VAT_Percent" Visible="false" runat="server" Text='<%# Eval("Order_Detail_VAT_Percent") %>' />
                                    <asp:Label ID="lbOrder_Detail_VAT" Visible="false" runat="server" Text='<%# Eval("Order_Detail_VAT") %>' />
                                    <asp:Label ID="lbOrder_Detail_Quality" Visible="false" runat="server" Text='<%# Eval("Order_Detail_Quality") %>' />
                                </td>

                                <td style="text-align:center">
                                    <asp:LinkButton ID="link_MaVatTu" runat="server" Text='<%# Eval("Materials_Alias") %>'></asp:LinkButton>
                                </td>

                                <td>
                                    <asp:LinkButton ID="link_TenVatTu" runat="server" Text='<%# Eval("Materials_Name") %>'></asp:LinkButton>
                                </td>

                                <td style="text-align:center">
                                   <asp:TextBox ID="txtSoLuong" CssClass="txtsoluong text-num text-num-order note" ClientIDMode="Static" onkeydown="txtOnKeyPress();" onKeyUp="txtOnKeyPress();" onkeypress="return ValidateKeypress(/\d/,event);" runat="server" Text="1" />
                                </td>

                                <td style="text-align:center">
                                    <asp:TextBox ID="txtDonGia" CssClass="txtdongia text-num text-num-order-1 note" ClientIDMode="Static" onkeydown="txtOnKeyPress();" onkeyup="this.value=FormatNumber(this.value);txtOnKeyPress();" runat="server" Text="0" />
                                </td>

                                <td style="text-align:center">
                                    <asp:TextBox ID="txtThanhTien" CssClass="txtthanhtien text-num text-num-order-1 note" ClientIDMode="Static" ReadOnly="true" runat="server" Text="0" />
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:ListView>
                </div>
            </div>
            <script type="text/javascript">
                function txtOnKeyPress() {

                    var txtSoLuong = document.getElementById('txtSoLuong');
                    var txtDonGia = document.getElementById('txtDonGia');

                    var txtThanhTien = document.getElementById('txtThanhTien');

                    if (txtSoLuong != 'undefined' && txtDonGia != 'undefined' && txtThanhTien != 'undefined') {

                        if (txtSoLuong.value == '') {
                            txtSoLuong.value = 1;
                            return false;
                        }
                        if (txtDonGia.value == '') {
                            txtDonGia.value = 0;
                            return false;
                        }
                        txtThanhTien.value = (parseFloat(txtSoLuong.value) * parseFloat(txtDonGia.value.replace(",", "")));
                        //alert(txtThanhTien.value);
                        txtThanhTien.value = FormatNumber(txtThanhTien.value.replace(",", ""));

                    }
                }
        </script>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="btnReloadPopup" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="btnAddMaterials_Popup" EventName="Click" />

            <asp:AsyncPostBackTrigger ControlID="drNguoiLapPhieu" EventName="SelectedIndexChanged" />
            <asp:AsyncPostBackTrigger ControlID="drChiNhanh" EventName="SelectedIndexChanged" />
            <asp:AsyncPostBackTrigger ControlID="drChonKho" EventName="SelectedIndexChanged" />
            <asp:AsyncPostBackTrigger ControlID="drPhongChua" EventName="SelectedIndexChanged" />
        </Triggers>
    </asp:UpdatePanel>
</div>

<div id="importmaterials" title="Thông tin vật tư">
    <asp:UpdatePanel ID="upDateMaterrials" UpdateMode="Conditional" ChildrenAsTriggers="true" runat="server">
        <ContentTemplate>
            <div class="grid-materials">
                <asp:TextBox ID="txtSearchUC" CssClass="textbox_child_search" placeholder="Nhập vào từ khoá tìm kiếm..." runat="server" />
                <div class="btn-group">
                    <asp:LinkButton ID="btnSearchUC" CssClass="btn btn-default btn-sm" runat="server" OnClick="btnSearchUC_Click"><i class="fa fa-search"></i> Tìm kiếm</asp:LinkButton>
                    <asp:LinkButton ID="btnReloadUC" CssClass="btn btn-default btn-sm" runat="server" OnClick="btnReloadUC_Click"><i class="fa fa-refresh"></i> Làm tươi</asp:LinkButton>
                    <asp:LinkButton ID="btnAddMaterials" CssClass="btn btn-default btn-sm" runat="server" OnClick="btnAddMaterials_Click"><i class="fa fa-pencil"></i> Chấp nhận</asp:LinkButton>
                </div>
            </div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSearchUC" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="btnReloadUC" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="btnAddMaterials" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>

    <asp:UpdateProgress ID="upDateProcessMaterials" runat="server" AssociatedUpdatePanelID="upDateMaterrials">
        <ProgressTemplate>
            <div class="divWaiting">
                <img src="../Images/ajax-loader.gif" alt="Loading"  />
                <span class="process-template-text">Đang tải dữ liệu...</span>
            </div>
        </ProgressTemplate>
    </asp:UpdateProgress>
</div>

<div id="orderimportdetail" title="Thông tin chi tiết phiếu nhập">
    <asp:UpdatePanel ID="upDateOrderImportDetail" UpdateMode="Conditional" ChildrenAsTriggers="true" runat="server">
        <ContentTemplate>

        </ContentTemplate>
        <Triggers>

        </Triggers>
    </asp:UpdatePanel>
</div>
<!--------------Kêt-thúc----------------->

<asp:UpdateProgress ID="upDateProcessOrderBy" runat="server" AssociatedUpdatePanelID="upDateOrderBuy">
    <ProgressTemplate>
        <div class="divWaiting">
            <img src="../Images/ajax-loader.gif" alt="Loading"  />
            <span class="process-template-text">Đang tải dữ liệu...</span>
        </div>
    </ProgressTemplate>
</asp:UpdateProgress>